<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>

<body>
    <script>
        let arr = [2, 6, 177, 52, 8]
        //声明一个保存最大元素的变量max
        let max = arr[0]
        for (i = 1; i <= arr.length; i++) {
            if (arr[i] > max) {
                max = arr[i]
            }
        }
        document.write(`最大值是${max}`)
    </script>
</body>

</html>